<template>
  <div class="app-container">
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" label-width="100px">
      <el-form-item label="税源地名称" prop="companyName">
        <el-input
          v-model="queryParams.companyName"
          placeholder="请输入税源地名称"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
        <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
      </el-form-item>
    </el-form>


    <el-table v-loading="loading" :data="taxList">
      <el-table-column label="税源名称" align="center" prop="companyName" min-width="200" />
      <el-table-column label="管理员名称" align="center" prop="administratorName" min-width="150"/>
      <el-table-column label="管理员手机号" align="center" prop="administratorPhone" min-width="160"/>
      <el-table-column label="可用余额" align="center" prop="agentMerchantBalance" min-width="110">
        <template slot-scope="{ row }">
          {{ row.balance?row.balance:0 }}元
        </template>
      </el-table-column>
      <el-table-column label="操作" align="center" class-name="fixed-width" min-width="180">
        <template slot-scope="scope">
          <el-button size="mini" type="text" icon="el-icon-more"  @click="handleBalanceRecord(scope.row.organizationId)">余额详情</el-button>
        </template>
      </el-table-column>
    </el-table>

  </div>
</template>

<script>
import {getSettlementList, listTaxTerritory} from "@/api/system/tax_territory";
import store from "@/store";
import {listTransferAccount} from "@/api/transfer/transferAccount";
export default {
  name:"plaform",
  data(){
    return {
      total:0,
      loading: true,
      taxList:[],
      queryParams:{
        auditStatus: 1,
        companyName:null,
      },
      detail:{},
      rechargeDetail:{},
      transferAccount:[],
      rechargeVisible:false,
      transferAccountIndex:0,
      organizationType: store.getters.organizationType,
    }
  },
  created() {
    this.getList();
  },
  methods:{
    /** 查询税源地列表 */
    getList() {
      this.loading = true;
      listTaxTerritory(this.queryParams).then(response => {
        this.taxList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },

    handleBalanceRecord(organizationId) {
      this.$emit("balanceRecord", organizationId)
    },

    handleRecharge(row) {
      this.detail = row
      listTransferAccount({ organizationId:row.organizationId }).then(res => {
        this.transferAccount = res.rows
        if (!this.transferAccount) {
          this.$modal.msgWarning("暂无充值账户");
        } else {
          this.transferAccountIndex = 0
          this.rechargeDetail = this.transferAccount[0]
          this.rechargeDetail.balance = row.balance
          this.rechargeVisible = true
        }
      })
    },

  }
}
</script>

<style scoped lang="scss">

</style>
